<template>
  <div>
    <el-form :model="form">
      <el-form-item label="سالون يازما ئادىرېرىسىنى كىرگۈزۈڭ:" label-width="200px">
        <el-input v-model="form.url" style="max-width:600px"></el-input>
      </el-form-item>
      <el-form-item label="كىنو ئادىرىسى:" label-width="200px">
        <el-input v-model="form.wxv" style="max-width:600px"></el-input>
      </el-form-item>
      <el-form-item label="" label-width="200px">
        <el-button @click="getMpWxv" type="primary" size="small">ئادىرىسىنى ئېلىش</el-button>
        <el-button @click="play" type="success" size="small">قويۇش</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getMpWxv } from '@/api/tools'
export default {
  name: 'GetWXV',
  components: {},
  data() {
    return {
      form: {
        wxv: 'wxv_1061261948332982272',
        url: "https://mp.weixin.qq.com/s/CFMztIlq5dNq9xkLOhgI5A"
      }
    };
  },
  methods: {
    getMpWxv() {
      this.$loading();
      getMpWxv({
        url: this.form.url
      }).then(res => {
        if (res) {
          this.$set(this.form, 'wxv', res)
        }
        this.$loading().close();
      }).catch(err => {
        this.$message.error('خاتالىق كۆرۈلدى')
        this.$loading().close();
      })
    },
    play() {
      let url = `https://mp.weixin.qq.com/mp/readtemplate?t=pages/video_player_tmpl&action=mpvideo&auto=0&vid=${this.form.wxv}`
      window.open(url, '_blank')
    }
  },
};
</script>

<style scoped lang="scss">
</style>
